package com.serverTechnology.craft.service.impl;


import cn.hutool.core.bean.BeanUtil;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.feign.serverLineFeign.LineFeign;
import com.feign.serverLineFeign.entity.ProcessMaterials;
import com.serverTechnology.craft.entity.dto.StandardParameterDto;
import com.serverTechnology.craft.entity.dto.StepsParameterInsertDto;

import com.serverTechnology.craft.entity.vo.StepsParameterVo;
import com.serverTechnology.craft.mapper.StepsParameterMapper;
import com.serverTechnology.craft.service.StepsParameterService;
import com.serverTechnology.craft.entity.StepsParameter;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 工步所需要的参数 服务实现类
 * </p>
 *
 * @author 王烁
 * @since 2024-08-01
 */
@Service
public class StepsParameterServiceImpl extends ServiceImpl<StepsParameterMapper, StepsParameter> implements StepsParameterService {
    @Autowired
    private StepsParameterMapper stepsParameterMapper;
    @Autowired
    private LineFeign lineFeign;

    @Override
    public List<StepsParameterVo> getStepsParameter(StandardParameterDto standardParameterDto) {
        List<StepsParameterVo> stepsParameterVos=stepsParameterMapper.getstepsParameterIdAnd(standardParameterDto);
        return stepsParameterVos;
    }

    @Override
    public void insertStepsParameter(StepsParameterInsertDto stepsParameter) {
        StepsParameter stepsParameterNow = new StepsParameter();
        BeanUtils.copyProperties(stepsParameter,stepsParameterNow);
        stepsParameterMapper.insert(stepsParameterNow);
    }

    @Override
    public void deleteStepsParameter(Long id) {
        stepsParameterMapper.delete(new LambdaQueryWrapper<StepsParameter>().eq(StepsParameter::getId,id));
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void updateStepsParameter(List<StepsParameterInsertDto> stepsParameter) {
        List<StepsParameter> stepsParameters = BeanUtil.copyToList(stepsParameter, StepsParameter.class);
        this.updateBatchById(stepsParameters);
    }


}
